Motion.SetAxisCamSwitch method

Uses an axis' position to control a switch that triggers a digital output. When an axis reaches a certain position, a switch is turned on or off. A switch can be controlled by a forward and backward movement of an axis.

Namespace: IntervalZero.KINGSTAR.OpcUa.Api

Assembly: IntervalZero.KINGSTAR.OpcUa.Api (in IntervalZero.KINGSTAR.OpcUa.Client.dll) Version: 4.4.0.0

Syntax

C#VB
public KsCommandStatus SetAxisCamSwitch(
       int Index,
       McCamSwitch[] Switches,
       McOutput[] Outputs,
       McTrack[] Tracks,
       uint EnableMask,
       McSource ValueSource
)
Public Function SetAxisCamSwitch(
       Index As Integer,
       Switches As McCamSwitch(),
       Outputs As McOutput(),
       Tracks As McTrack(),
       EnableMask As UInteger,
       ValueSource As McSource
) As KsCommandStatus

Parameters

Index [in]

Type: int

The index of an axis. Indexes are zero based. Aliases affect this parameter.

 

Switches [in]

Type: McCamSwitch[]

Controls the switching actions. The track numbers need to be in order.

 

Outputs [in]

Type: McOutput[]

Selects which digital output will be controlled by the corresponding track.

 

Tracks [in]

Type: McTrack[]

Adds the compensation time and hysteresis to the switches on a track. TrackNumber is defined in Switches.

 

EnableMask [in]

Type: uint

Enables the different tracks. This parameter is 32 bits of bool. The corresponding track in the track array is enabled when its bool value is set to one.

 

ValueSource [in]

Type: McSource

Defines the source for axis values. For example, positions. See McSource.

Return value

Type: KsCommandStatus

Returns the KsCommandStatus class.

Remarks

Elements within McCamSwitch Class

B/E Parameter Type Description
B TrackNumber INT The index of the track. Indexes are zero-based.
B FirstOnPosition [user unit] LREAL The position from which the switch is on.
B LastOnPosition [user unit] LREAL The position from which the switch is off.
E AxisDirection INT

The direction of the axis. The default value is zero. If you select one or two, the switch is active only when the axis is moving in the specified direction.

Both: 0, Positive: 1, Negative: 2.

E CamSwitchMode INT

The cam switch is controlled by axis' positions or time. The default value is zero. If choosing Position, you need to set FirstOnPosition and LastOnPosition; if choosing Time, you need to set FirstOnPosition and Duration.

Position: 0, Time: 1.

E Duration TIME How long the switch is on. This property is available when CamSwitchMode is Time. The unit is second.

 

Elements within McTrack Class

B/E Parameter Type Description
E OnCompensation TIME Compensation time with which the switch is turned on (rising edge) before or after the switching point per track. If the value is positive, the switch-on will be delayed; if the value is negative, the switch-on will be advanced.
E OffCompensation TIME Compensation time with which the switch is turned off (falling edge) before or after the switching point per track. If the value is positive, the switch-off will be delayed; if the value is negative, the switch-off will be advanced.
E Hysteresis [unit] LREAL Distance from the switching point (in positive and negative direction) in which the switch is not turned on or off until the axis has left this area. This can avoid multiple switching around the switching point.

 

This definition of a cam has a start and an end position, so the user can define each single cam, which has a FirstOnPosition and a LastOnPosition (or time). This function is similar to a mechanical cam but has the additional advantages that the outputs can be set for a certain time, and to give it a time-compensation and a hysteresis.

CamSwitchMode: It can be position or time.

Duration: Time, the output of a time cam is ON. The time compensation (OnCompensation and OffCompensation) can be positive or negative. Negative means the output changes before the switching position is reached.

Hysteresis: This parameter avoids the phenomenon where the output continually switches if the axis is near the switching point and the actual position is jittering around the switching position. Hysteresis is part of McTrack, which means that a different hysteresis is possible for each track.

 

Example of McCamSwitch

Parameter Type Switch01 Switch02 Switch03 Switch04 ... SwitchN
TrackNumber INTEGER 1 1 1 2    
FirstOnPosition [unit] LREAL 2000 2500 4000 3000    
LastOnPosition [unit] LREAL 3000 3000 6000 --    
AxisDirection INTEGER 1=Pos 2=Neg 0=Both 0=Both    
CamSwitchMode INTEGER 0=Position 0=Position 0=Position 1=Time    
Duration LREAL -- -- -- 1.35 seconds    

 

Example of McOutput

Parameter MC_OUTPUT[0] MC_OUTPUT[1] MC_OUTPUT[2] - - - MC_OUTPUT[31]
IsAxis FALSE FALSE FALSE - - - FALSE
Index 0 0 0 - - - 0
BitOffset 0 1 2 - - - 31

 

Example of an I/O module

 

The figure below uses the values from the example of McCamSwitch above. It uses neither On/OffCompensation nor Hysteresis. This is the behavior of the outputs, when the axis is moving continuously in the positive direction.

 

SetAxisCamSwitch – Positive Direction

 

Positive Direction: Behavior of the Outputs

TrackNumber 1 (Switch01, 02, 03) is mapped to McOutput[1] and TrackNumber 2 (Switch04) is mapped to McOutput[2]. When Switch01, Switch02, and Switch03 are triggered, the second output (Output 1) on the first I/O module (Index 0) is turned on. When Switch04 is triggered, the third output is turned on (Output 2).

 

Example of On/Off Compensation

This example uses OnCompensation -125ms and OffCompensation +250ms.

 

The figure below shows the behavior of the outputs, when the axis is moving continuously in the negative direction without On/OffCompensation and without Hysteresis.

 

SetAxisCamSwitch – Negative Direction

 

Negative Direction: Behavior of the Outputs

 

EnableMask

EnableMask is an uint32 parameter that contains 32 bits. Each bit is a BOOL value that controls an output. An output is enabled or disabled by setting its corresponding bit TRUE or FALSE. For example, bit 0 controls McOutput[0] and bit 1 controls McOutput[1]. If bit 0 and 1 are TRUE, their outputs are enabled, which means their outputs will be turned on when their corresponding switches are triggered; if they are FALSE, their outputs are disabled, which means their outputs won't be turned on even if their corresponding switches are triggered.

Bits Bit 0 Bit 1 Bit 2 Bit 3 - - - - Bit 31
Value TRUE/FALSE TRUE/FALSE TRUE/FALSE TRUE/FALSE - - - - TRUE/FALSE

 

Example of McOutput

Parameter MC_OUTPUT[0] MC_OUTPUT[1] MC_OUTPUT[2] - - - MC_OUTPUT[31]
IsAxis FALSE FALSE FALSE - - - FALSE
Index 0 0 0 - - - 0
BitOffset 0 1 2 - - - 31

 

Example 1 of EnableMask Bits

Bit 0, 1, and 2 are TRUE, which means Output 0, 1, and 2 are enabled. The outputs are turned on when their corresponding switches are triggered.

Bits Bit 0 Bit 1 Bit 2 Bit 3 - - - - Bit 31
Value TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE

 

Positive Direction: Behavior of the Outputs

 

Example 2 of EnableMask Bits

Bit 0 and 2 are TRUE, which means Output 0 and 2 are enabled. Only these two outputs are turned on when their corresponding switches are triggered.

Bits Bit 0 Bit 1 Bit 2 Bit 3 - - - - Bit 31
Value TRUE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE

 

Positive Direction: Behavior of the Outputs

 

Example 3 of EnableMask Bits

All bits are FALSE, which means all outputs are disabled. No outputs are turned on even if their corresponding switches are triggered.

Bits Bit 0 Bit 1 Bit 2 Bit 3 - - - - Bit 31
Value FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

 

Positive Direction: Behavior of the Outputs

Examples

C#
N/A

See also

Motion Class

IntervalZero.KINGSTAR.OpcUa.Api Namespace